package net;

import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.channel.Channels;
import org.jboss.netty.handler.timeout.IdleStateHandler;
import org.jboss.netty.util.HashedWheelTimer;
import org.jboss.netty.util.Timer;

public class ServerPipelineFactory implements ChannelPipelineFactory {
	private Timer _idelTimer;
	private IdleStateHandler _idelHandler;

	public ServerPipelineFactory(int timeout) {
		_idelTimer = new HashedWheelTimer();
		_idelHandler = new IdleStateHandler(_idelTimer, timeout, 
				timeout, timeout);
	}

	public ChannelPipeline getPipeline() throws Exception {
		ChannelPipeline pipeline = Channels.pipeline(_idelHandler,
				new IdelEventHandler(),
				new ExtractFrame(1024));
//				new ServerSocketHandler(null));
		return pipeline;
	}
}
